{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Pebblo Safe DocumentLoader\n",
    "\n",
    "> [Pebblo](https://github.com/daxa-ai/pebblo) enables developers to safely load data and promote their Gen AI app to deployment without worrying about the organization’s compliance and security requirements. The project identifies semantic topics and entities found in the loaded data and summarizes them on the UI or a PDF report.\n",
    "\n",
    "Pebblo has two components.\n",
    "\n",
    "1. Pebblo Safe DocumentLoader for Langchain\n",
    "1. Pebblo Daemon\n",
    "\n",
    "This document describes how to augment your existing Langchain DocumentLoader with Pebblo Safe DocumentLoader to get deep data visibility on the types of Topics and Entities ingested into the Gen-AI Langchain application. For details on `Pebblo Daemon` see this [pebblo daemon](https://daxa-ai.github.io/pebblo-docs/daemon.html) document.\n",
    "\n",
    "Pebblo Safeloader enables safe data ingestion for Langchain `DocumentLoader`. This is done by wrapping the document loader call with `Pebblo Safe DocumentLoader`.\n",
    "\n",
    "#### How to Pebblo enable Document Loading?\n",
    "\n",
    "Assume a Langchain RAG application snippet using `CSVLoader` to read a CSV document for inference.\n",
    "\n",
    "Here is the snippet of Document loading using `CSVLoader`."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from langchain.document_loaders.csv_loader import CSVLoader\n",
    "\n",
    "loader = CSVLoader(\"data/corp_sens_data.csv\")\n",
    "documents = loader.load()\n",
    "print(documents)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The Pebblo SafeLoader can be enabled with few lines of code change to the above snippet."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from langchain.document_loaders.csv_loader import CSVLoader\n",
    "from langchain_community.document_loaders import PebbloSafeLoader\n",
    "\n",
    "loader = PebbloSafeLoader(\n",
    "    CSVLoader(\"data/corp_sens_data.csv\"),\n",
    "    name=\"acme-corp-rag-1\",  # App name (Mandatory)\n",
    "    owner=\"Joe Smith\",  # Owner (Optional)\n",
    "    description=\"Support productivity RAG application\",  # Description (Optional)\n",
    ")\n",
    "documents = loader.load()\n",
    "print(documents)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": ".venv",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
